{% extends 'base.html' %}

{% block title %}{{ restaurant.name }} - 菜单{% endblock %}

{% block content %}
<h1 class="mb-4">{{ restaurant.name }} - 菜单</h1>

<form method="post" action="{% url 'order_create' restaurant.id %}">
    {% csrf_token %}
    
    <div class="mb-3">
        <label for="delivery_address" class="form-label">配送地址</label>
        <textarea class="form-control" id="delivery_address" name="delivery_address" required></textarea>
    </div>

    <div class="row">
        {% for item in menu_items %}
        <div class="col-md-4 mb-4">
            <div class="card">
                <div class="card-body">
                    <h5 class="card-title">{{ item.name }}</h5>
                    <p class="card-text">{{ item.description }}</p>
                    <p class="card-text">
                        <strong>价格：¥{{ item.price }}</strong>
                    </p>
                    <div class="input-group">
                        <span class="input-group-text">数量</span>
                        <input type="number" class="form-control" name="item_{{ item.id }}" min="0" value="0">
                    </div>
                </div>
            </div>
        </div>
        {% empty %}
        <div class="col">
            <p>暂无可用菜品</p>
        </div>
        {% endfor %}
    </div>

    {% if menu_items %}
    <button type="submit" class="btn btn-primary">提交订单</button>
    {% endif %}
</form>
{% endblock %}